package com.wdcloud.netlibrary.platform;

import com.wdcloud.netlibrary.request.ByteRequest;
import com.wdcloud.netlibrary.request.DownLoadRequest;
import com.wdcloud.netlibrary.request.GetRequest;
import com.wdcloud.netlibrary.request.IRequestBuild;
import com.wdcloud.netlibrary.request.JsonRequest;
import com.wdcloud.netlibrary.request.MultiRequest;
import com.wdcloud.netlibrary.request.PostRequest;
import com.wdcloud.netlibrary.util.OkHttpUtil;

import java.util.Map;


/**
 *
 */
public class OkHttpPlatform implements Platform {


    /**
     * get请求
     *
     * @return
     */
    public GetRequest doGet() {
        return new GetRequest();
    }

    /**
     * post请求
     *
     * @return
     */
    public PostRequest doPost() {
        return new PostRequest();
    }


    @Override
    public IRequestBuild doJsonPost() {
        return new JsonRequest();
    }


    @Override
    public IRequestBuild doBytePost() {
        return new ByteRequest();
    }

    /**
     * fileUpload请求
     * @return
     */
    public MultiRequest doUploadFile() {
        return new MultiRequest();
    }


    /**
     * 文件下载
     */
    public DownLoadRequest downLoadFile() {
        return new DownLoadRequest();
    }


    /**
     * 取消任务
     *
     * @param
     */
    public void cancel(Object o) {
        OkHttpUtil.getInstance().cancel(o);
    }


    @Override
    public void setProxy(Map<String, Object> map) {
        OkHttpUtil.getInstance().setProxy(map);
    }


    @Override
    public void setCookie(String key, String value) {
        OkHttpUtil.getInstance().setCookie(key, value);
    }
}
